package com.asa.photopicker.photo;

import com.asa.photopicker.R;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;

public class PhotoActivity extends FragmentActivity {
	public final static String EXTRA_MAX_COUNT = "max_count";

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_photo_layout);
		int maxCount = getIntent().getIntExtra(EXTRA_MAX_COUNT, MessageSelectMediaFragment.DEFAULT_MAX_IMAGE_COUNT);
		FragmentManager manager = getSupportFragmentManager();
		FragmentTransaction transaction = manager.beginTransaction();
		transaction.add(R.id.fragment_containt, MessageSelectMediaFragment.newInstance(maxCount));
		transaction.commitAllowingStateLoss();
	}

	public static void startMe(Activity activity, int maxCount, int requestCode) {
		Intent intent = new Intent();
		intent.setClass(activity, PhotoActivity.class);
		intent.putExtra(EXTRA_MAX_COUNT, maxCount);
		if (requestCode > 0) {
			activity.startActivityForResult(intent, requestCode);
		} else {
			activity.startActivity(intent);
		}
	}
}
